<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong>{{ unDone }}</strong></span>
    <ul class="filters">
      <li>
        <a @click="$emit('setActive' ,'all')" :class="{ selected :active === 'all'}" href="javascript:;" >全部</a>
      </li>
      <li>
        <a @click="$emit('setActive' ,'undone')" :class="{ selected :active === 'undone'}" href="javascript:;">未完成</a>
      </li>
      <li>
        <a @click="$emit('setActive' ,'done')" :class="{ selected :active === 'done'}" href="javascript:;" >已完成</a>
      </li>
    </ul>
    <button class="clear-completed" @click="clearDone">清除已完成</button>
  </footer>
</template>


<script>
export default {
  props: ['arr', 'active'],
  computed: {
    // 计算未完成的数据
    unDone() {
      return this.arr.filter(item => !item.isDone).length
    }
  },
  methods: {
    // 清除已完成
    clearDone() {
      const unDone = this.arr.filter(item => !item.isDone)
      this.$emit('onClear', unDone)
    }
  }
}
</script>